<html><head><style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.linenumber {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='linenumber'>  1</span> <span class="COMM">/*
<span class='linenumber'>  2</span>  * Licensed to the Apache Software Foundation (ASF) under one
<span class='linenumber'>  3</span>  * or more contributor license agreements.  See the NOTICE file
<span class='linenumber'>  4</span>  * distributed with this work for additional information
<span class='linenumber'>  5</span>  * regarding copyright ownership.  The ASF licenses this file
<span class='linenumber'>  6</span>  * to you under the Apache License, Version 2.0 (the
<span class='linenumber'>  7</span>  * "License"); you may not use this file except in compliance
<span class='linenumber'>  8</span>  * with the License.  You may obtain a copy of the License at
<span class='linenumber'>  9</span>  *
<span class='linenumber'> 10</span>  *     http://www.apache.org/licenses/LICENSE-2.0
<span class='linenumber'> 11</span>  *
<span class='linenumber'> 12</span>  * Unless required by applicable law or agreed to in writing,
<span class='linenumber'> 13</span>  * software distributed under the License is distributed on an
<span class='linenumber'> 14</span>  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
<span class='linenumber'> 15</span>  * KIND, either express or implied.  See the License for the
<span class='linenumber'> 16</span>  * specific language governing permissions and limitations
<span class='linenumber'> 17</span>  * under the License.
<span class='linenumber'> 18</span>  */</span><span class="WHIT">
<span class='linenumber'> 19</span> 
<span class='linenumber'> 20</span> </span><span class="COMM">/**
<span class='linenumber'> 21</span>  * @fileoverview A wrapper SDK for opensocial javascript API into actionscript.
<span class='linenumber'> 22</span>  * &lt;p>
<span class='linenumber'> 23</span>  * It works with the Opensocial Actionscript Client SDK lib. In this file, it communicates between 
<span class='linenumber'> 24</span>  * swf functions and the gadgets/opensocial javascript API functions. 
<span class='linenumber'> 25</span>  * &lt;/p>
<span class='linenumber'> 26</span>  * &lt;p>
<span class='linenumber'> 27</span>  * TODO: Provide a compiled version.
<span class='linenumber'> 28</span>  * &lt;/p>
<span class='linenumber'> 29</span>  * 
<span class='linenumber'> 30</span>  * @see http://code.google.com/apis/opensocial/docs/0.8/reference/
<span class='linenumber'> 31</span>  * @version 0.8
<span class='linenumber'> 32</span>  * @author yiziwu@google.com (Yizi Wu)
<span class='linenumber'> 33</span>  */</span><span class="WHIT">
<span class='linenumber'> 34</span> 
<span class='linenumber'> 35</span> </span><span class="COMM">//======================== External Namespace ==================================</span><span class="WHIT">
<span class='linenumber'> 36</span> </span><span class="COMM">/**
<span class='linenumber'> 37</span>  * @static
<span class='linenumber'> 38</span>  * @class External namespace for &lt;code>gadgets&lt;/code> for internal reference.
<span class='linenumber'> 39</span>  * @name gadgets
<span class='linenumber'> 40</span>  */</span><span class="WHIT">
<span class='linenumber'> 41</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'gadgets'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 42</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">gadgets</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 43</span>   </span><span class="NAME">INFO</span><span class="PUNC">(</span><span class="STRN">'gadgets.* not found.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 44</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 45</span> 
<span class='linenumber'> 46</span> 
<span class='linenumber'> 47</span> </span><span class="COMM">/**
<span class='linenumber'> 48</span>  * @static
<span class='linenumber'> 49</span>  * @class External namespace for &lt;code>opensocial&lt;/code> for internal reference.
<span class='linenumber'> 50</span>  * @name opensocial
<span class='linenumber'> 51</span>  */</span><span class="WHIT">
<span class='linenumber'> 52</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'opensocial'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 53</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">opensocial</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 54</span>   </span><span class="NAME">INFO</span><span class="PUNC">(</span><span class="STRN">'opensocial.* not found.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 55</span>   </span><span class="NAME">opensocial</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 56</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 57</span> 
<span class='linenumber'> 58</span> </span><span class="COMM">//======================== Opensocial Flash Namespace ==================================</span><span class="WHIT">
<span class='linenumber'> 59</span> </span><span class="COMM">/**
<span class='linenumber'> 60</span>  * @static
<span class='linenumber'> 61</span>  * @class Namespace for top-level api functions.
<span class='linenumber'> 62</span>  * @requires opensocial
<span class='linenumber'> 63</span>  * @name opensocial.flash
<span class='linenumber'> 64</span>  */</span><span class="WHIT">
<span class='linenumber'> 65</span> </span><span class="NAME">opensocial.flash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 66</span>   
<span class='linenumber'> 67</span>   </span><span class="COMM">//======================== FLAGS and Debugging Tools (private) =================================</span><span class="WHIT">
<span class='linenumber'> 68</span>   </span><span class="COMM">/** 
<span class='linenumber'> 69</span>    * Flag for JSCompiler is any.
<span class='linenumber'> 70</span>    * @type {boolean}
<span class='linenumber'> 71</span>    * @private
<span class='linenumber'> 72</span>    */</span><span class="WHIT">
<span class='linenumber'> 73</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">COMPILED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 74</span>   
<span class='linenumber'> 75</span>   </span><span class="COMM">/** 
<span class='linenumber'> 76</span>    * Set to false for release. 
<span class='linenumber'> 77</span>    * @type {boolean}
<span class='linenumber'> 78</span>    * @private
<span class='linenumber'> 79</span>    */</span><span class="WHIT">
<span class='linenumber'> 80</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 81</span>   
<span class='linenumber'> 82</span> 
<span class='linenumber'> 83</span>   </span><span class="COMM">/**
<span class='linenumber'> 84</span>    * For debugging, return the object's keys and values.
<span class='linenumber'> 85</span>    * @param {Object?} obj Any object to be looked into.
<span class='linenumber'> 86</span>    * @param {string?} opt_prefix The prefix string of each output line.
<span class='linenumber'> 87</span>    * @param {string?} opt_rendered The rendered string passing between recursions.
<span class='linenumber'> 88</span>    * @return {string?} A tree-style string to represent the object.
<span class='linenumber'> 89</span>    * @private
<span class='linenumber'> 90</span>    */</span><span class="WHIT">
<span class='linenumber'> 91</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">debugInspect</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_prefix</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 92</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">opt_rendered</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 93</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">opt_prefix</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">opt_prefix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 94</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 95</span>     </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 96</span>       </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> 
<span class='linenumber'> 97</span>           </span><span class="PUNC">(</span><span class="NAME">opt_prefix</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] : '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 98</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 99</span>         </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> 
<span class='linenumber'>100</span>             </span><span class="NAME">debugInspect</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_prefix</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\t'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>101</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>102</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>103</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>104</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>105</span>   
<span class='linenumber'>106</span>   </span><span class="COMM">/**
<span class='linenumber'>107</span>    * For debugging, export the local variables to global.
<span class='linenumber'>108</span>    * Only available when DEBUG = true.
<span class='linenumber'>109</span>    * @param {string} name The name.
<span class='linenumber'>110</span>    * @param {Object?} value The value.
<span class='linenumber'>111</span>    * @private
<span class='linenumber'>112</span>    */</span><span class="WHIT">
<span class='linenumber'>113</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">debugExport</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>114</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>115</span>       </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'debug'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'debug'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>116</span>       </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'debug'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>117</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>118</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>119</span>   
<span class='linenumber'>120</span>   </span><span class="COMM">/**
<span class='linenumber'>121</span>    * For debugging, output text information to firebug console.
<span class='linenumber'>122</span>    * Only available when DEBUG = true.
<span class='linenumber'>123</span>    * @param {Object?} content The content to be logged.
<span class='linenumber'>124</span>    * @private
<span class='linenumber'>125</span>    */</span><span class="WHIT">
<span class='linenumber'>126</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">debugInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>127</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">window.console</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>128</span>       </span><span class="NAME">window.console.info</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>129</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>130</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>131</span> 
<span class='linenumber'>132</span>   </span><span class="COMM">/**
<span class='linenumber'>133</span>    * For debugging, log the object to firebug console.
<span class='linenumber'>134</span>    * Only available when DEBUG = true.
<span class='linenumber'>135</span>    * @param {Object?} content The content to be logged.
<span class='linenumber'>136</span>    * @private
<span class='linenumber'>137</span>    */</span><span class="WHIT">
<span class='linenumber'>138</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">debugLog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>139</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">window.console</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>140</span>       </span><span class="NAME">window.console.log</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>141</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>142</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>143</span> 
<span class='linenumber'>144</span>   </span><span class="COMM">// Export these debugging functions for shortcuts</span><span class="WHIT">
<span class='linenumber'>145</span>   </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>146</span>     </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"INFO"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">debugInfo</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>147</span>     </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"LOG"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">debugLog</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>148</span>     </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"INSPECT"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">debugInspect</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>149</span>     </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"EXPORT"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">debugExport</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>150</span>   </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>151</span> 
<span class='linenumber'>152</span> 
<span class='linenumber'>153</span>   </span><span class="COMM">//======================== Common Util Helper Functions (private) ===========================</span><span class="WHIT">
<span class='linenumber'>154</span>   
<span class='linenumber'>155</span>   </span><span class="COMM">/**
<span class='linenumber'>156</span>    * Checks if the object is an array.
<span class='linenumber'>157</span>    * @param {Object} obj object to be check.
<span class='linenumber'>158</span>    * @return {boolean} True if the object is an array.
<span class='linenumber'>159</span>    * @private
<span class='linenumber'>160</span>    */</span><span class="WHIT">
<span class='linenumber'>161</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isArray</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>162</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>163</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>164</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>165</span>     </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>166</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='linenumber'>167</span>           </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='linenumber'>168</span>           </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj.splice</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>169</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>170</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>171</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>172</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>173</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>174</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>175</span>   
<span class='linenumber'>176</span>   </span><span class="COMM">/**
<span class='linenumber'>177</span>    * Iterates an array, calls the function for each item.
<span class='linenumber'>178</span>    * @param {Array} array The array to be iterated.
<span class='linenumber'>179</span>    * @param {Function} f The function to be applied.
<span class='linenumber'>180</span>    * @param {Object} opt_thisObj The this object for the function.
<span class='linenumber'>181</span>    * @private
<span class='linenumber'>182</span>    */</span><span class="WHIT">
<span class='linenumber'>183</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_thisObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>184</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">array.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>185</span>       </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>186</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>187</span>     </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">array.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>188</span>     </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>189</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>190</span>         </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">false</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">f.call</span><span class="PUNC">(</span><span class="NAME">opt_thisObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>191</span>           </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>192</span>         </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>193</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>194</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>195</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>196</span>   
<span class='linenumber'>197</span>   
<span class='linenumber'>198</span>   </span><span class="COMM">/**
<span class='linenumber'>199</span>    * Deeply clones an object.
<span class='linenumber'>200</span>    * @param {Object?} obj The original object.
<span class='linenumber'>201</span>    * @return {Object?} The cloned object.
<span class='linenumber'>202</span>    * @private
<span class='linenumber'>203</span>    */</span><span class="WHIT">
<span class='linenumber'>204</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>205</span>     </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>206</span>     </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>207</span>       </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">:</span><span class="WHIT">
<span class='linenumber'>208</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>209</span>       </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">:</span><span class="WHIT"> 
<span class='linenumber'>210</span>         </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">newObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">obj.constructor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>211</span>         </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">newObj</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>212</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">newObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>213</span>       </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='linenumber'>214</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj.valueOf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>215</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>216</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>217</span> 
<span class='linenumber'>218</span>   </span><span class="COMM">//======================== Opensocial Data Helper Functions (private) ===========================</span><span class="WHIT">
<span class='linenumber'>219</span>   </span><span class="COMM">/**
<span class='linenumber'>220</span>    * Gets data object from resoponse.
<span class='linenumber'>221</span>    * @param {opensocial.DataResponse} dataResponse The response object.
<span class='linenumber'>222</span>    * @param {string} key The data key in the response object.
<span class='linenumber'>223</span>    * @throws {Error} When the RPC meets error.
<span class='linenumber'>224</span>    * @return {Object?} The data, can be any instance of the opensocial.* data type.
<span class='linenumber'>225</span>    * @private
<span class='linenumber'>226</span>    */</span><span class="WHIT">
<span class='linenumber'>227</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getData</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>228</span>     </span><span class="COMM">// for debug</span><span class="WHIT">
<span class='linenumber'>229</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>230</span>       </span><span class="NAME">EXPORT</span><span class="PUNC">(</span><span class="STRN">'DATA_RESPONSE'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'key'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'data'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dataResponse</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>231</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>232</span>     
<span class='linenumber'>233</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>234</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dataResponse.hadError</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>235</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">dataResponse.getErrorMessage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>236</span>       </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"OpensocialError"</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>237</span>       </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>238</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>239</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>240</span>     
<span class='linenumber'>241</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">getDataItem</span><span class="PUNC">(</span><span class="NAME">dataResponse.get</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>242</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>243</span>   
<span class='linenumber'>244</span>   </span><span class="COMM">/**
<span class='linenumber'>245</span>    * Gets data object from response item.
<span class='linenumber'>246</span>    * @param {opensocial.ResponseItem} responseItem The response item object.
<span class='linenumber'>247</span>    * @throws {Error} When the items have errors.
<span class='linenumber'>248</span>    * @return {Object?} The data, can be any instance of the opensocial.* data type.
<span class='linenumber'>249</span>    * @private
<span class='linenumber'>250</span>    */</span><span class="WHIT">
<span class='linenumber'>251</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>252</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>253</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">responseItem.hadError</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>254</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">responseItem.getErrorMessage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>255</span>       </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"OpensocialError"</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>256</span>       </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'code'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">responseItem.getErrorCode</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>257</span>       </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>258</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>259</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">responseItem.getData</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>260</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>261</span>   
<span class='linenumber'>262</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dataTypes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Address'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'BodyType'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Email'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Name'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Organization'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Phone'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Url'</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>263</span>       </span><span class="STRN">'Enum'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Person'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Activity'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'IdSpec'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'MediaItem'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Message'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'NavigationParameters'</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>264</span>       </span><span class="STRN">'Collection'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">    
<span class='linenumber'>265</span>   </span><span class="COMM">/**
<span class='linenumber'>266</span>    * Gets the constructor function for opensocial data object.
<span class='linenumber'>267</span>    * @param {Object} dataObj The object to be checked.
<span class='linenumber'>268</span>    * @return {Function?} The type of the object.
<span class='linenumber'>269</span>    * @private
<span class='linenumber'>270</span>    */</span><span class="WHIT">
<span class='linenumber'>271</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">checkType</span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>272</span>     </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>273</span>     </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">dataTypes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">typeItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>274</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">typeItem</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">dataObj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="PUNC">[</span><span class="NAME">typeItem</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>275</span>         </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="PUNC">[</span><span class="NAME">typeItem</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>276</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>277</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>278</span>     </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>279</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>280</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>281</span>   
<span class='linenumber'>282</span>   </span><span class="COMM">/**
<span class='linenumber'>283</span>    * Wraps the opensocial rich object (with functions) to a JSON-like flat serializable object.
<span class='linenumber'>284</span>    * So the object can pass through the &lt;code>ExternalInterface&lt;/code> to the swf.
<span class='linenumber'>285</span>    * @param {Object} dataObj The object to be wrapped.
<span class='linenumber'>286</span>    * @param {Object?} opt_this The flat object as a container to hold the wrapped fields.
<span class='linenumber'>287</span>    * @return {Object?} A wrapped flat object, ready to pass to swf.
<span class='linenumber'>288</span>    * @private
<span class='linenumber'>289</span>    */</span><span class="WHIT">
<span class='linenumber'>290</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>291</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>292</span> 
<span class='linenumber'>293</span>     </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">checkType</span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>294</span>   
<span class='linenumber'>295</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>296</span>       </span><span class="COMM">// treat it as string</span><span class="WHIT">
<span class='linenumber'>297</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">dataObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>298</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>299</span>    
<span class='linenumber'>300</span>     </span><span class="COMM">// fix fields</span><span class="WHIT">
<span class='linenumber'>301</span>     </span><span class="NAME">opt_this</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>302</span>     
<span class='linenumber'>303</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'Field'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">    
<span class='linenumber'>304</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>305</span> 
<span class='linenumber'>306</span>       </span><span class="COMM">// Grabs the fields data from each structures recursively.</span><span class="WHIT">
<span class='linenumber'>307</span>       </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">type.Field</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>308</span>         </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type.Field</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>309</span>         </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getField</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>310</span>         </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>311</span>           </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isArray</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>312</span>             </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>313</span>             </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>314</span>               </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>315</span>             </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>316</span>           </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>317</span>             </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>318</span>           </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>319</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>320</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>321</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>322</span>     
<span class='linenumber'>323</span>     </span><span class="COMM">// fix properties.</span><span class="WHIT">
<span class='linenumber'>324</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Person</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>325</span>       
<span class='linenumber'>326</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'displayName'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getDisplayName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>327</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'isOwner'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.isOwner</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>328</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'isViewer'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.isViewer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>329</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'id'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getId</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>330</span>       
<span class='linenumber'>331</span>     </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Activity</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>332</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'id'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getId</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>333</span>       
<span class='linenumber'>334</span>     </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Enum</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>335</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'key'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getKey</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>336</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'displayValue'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getDisplayValue</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>337</span> 
<span class='linenumber'>338</span>     </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Collection</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>339</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'size'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.size</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>340</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'offset'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getOffset</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>341</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'totalSize'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getTotalSize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>342</span>       
<span class='linenumber'>343</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.asArray</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>344</span>       </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'array'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>345</span>       </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>346</span>         </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'array'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>347</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>348</span>       
<span class='linenumber'>349</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>350</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>351</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>352</span>   
<span class='linenumber'>353</span>   </span><span class="COMM">/**
<span class='linenumber'>354</span>    * Unwraps the flattened object to a rich opensocial data object. The flattened object is come 
<span class='linenumber'>355</span>    * from the swf via &lt;code>ExternalInterface&lt;/code>.
<span class='linenumber'>356</span>    * @param {Object} obj The object to be unwrapped. Only those 5 types with &lt;code>setField&lt;/code>
<span class='linenumber'>357</span>    *                 method and &lt;code>opensocial.newXXXX&lt;/code> creator can be unwrapped.
<span class='linenumber'>358</span>    * @param {Function} type The object's target type to be unwrapped.
<span class='linenumber'>359</span>    * @throws {Error} When the type is not correct.
<span class='linenumber'>360</span>    * @return {Object} Unwrapped rich opensocial data object, ready to use in javascript. 
<span class='linenumber'>361</span>    * @private
<span class='linenumber'>362</span>    */</span><span class="WHIT">
<span class='linenumber'>363</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>364</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'fields'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>365</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>366</span>     
<span class='linenumber'>367</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>368</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newIdSpec</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>369</span>         
<span class='linenumber'>370</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.NavigationParameters</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>371</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newNavigationParameters</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>372</span>         
<span class='linenumber'>373</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.MediaItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>374</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newMediaItem</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.MediaItem.Field.MIME_TYPE</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>375</span>                                        </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.MediaItem.Field.URL</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>376</span>                                        </span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>377</span> 
<span class='linenumber'>378</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>379</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newMessage</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.Message.Field.BODY</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>380</span>                                      </span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>381</span>         
<span class='linenumber'>382</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Activity</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>383</span>         </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">flatItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.Activity.Field.MEDIA_ITEMS</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>384</span>         </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isArray</span><span class="PUNC">(</span><span class="NAME">flatItems</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>385</span>           </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">richItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>386</span>           </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">flatItems</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>387</span>             </span><span class="NAME">richItems.push</span><span class="PUNC">(</span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.MediaItem</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>388</span>           </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>389</span>           </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.Activity.Field.MEDIA_ITEMS</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">richItems</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>390</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>391</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newActivity</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>392</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>393</span>     
<span class='linenumber'>394</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>395</span>     </span><span class="COMM">// If reaches here, codes are wrong.</span><span class="WHIT">
<span class='linenumber'>396</span>     </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">'The object does not has fields values or type mismatched.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>397</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>398</span>   
<span class='linenumber'>399</span>   </span><span class="COMM">/**
<span class='linenumber'>400</span>    * When any data request error happens, log down the error and callback to swf.
<span class='linenumber'>401</span>    * @param {string} reqID The request ID.
<span class='linenumber'>402</span>    * @param {Error} error The error thrown during the response.
<span class='linenumber'>403</span>    * @private
<span class='linenumber'>404</span>    */</span><span class="WHIT">
<span class='linenumber'>405</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>406</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>407</span>       </span><span class="NAME">INFO</span><span class="PUNC">(</span><span class="NAME">error</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>408</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>409</span>     </span><span class="NAME">swfObj.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>410</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>411</span> 
<span class='linenumber'>412</span> 
<span class='linenumber'>413</span>   </span><span class="COMM">//======================== Flash Embeded Object Varibles (private) ===========================</span><span class="WHIT">
<span class='linenumber'>414</span>   </span><span class="COMM">/**
<span class='linenumber'>415</span>    * The flash movie object which apply this API.
<span class='linenumber'>416</span>    * This object is initialized in &lt;code>opensocial.flash.jsReady&lt;/code> function.
<span class='linenumber'>417</span>    * @type {HTMLElement}
<span class='linenumber'>418</span>    * @private
<span class='linenumber'>419</span>    */</span><span class="WHIT">
<span class='linenumber'>420</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">swfObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>421</span> 
<span class='linenumber'>422</span>   </span><span class="COMM">/**
<span class='linenumber'>423</span>    * The default flash id embeded in container.
<span class='linenumber'>424</span>    * @type {string}
<span class='linenumber'>425</span>    * @private
<span class='linenumber'>426</span>    */</span><span class="WHIT">
<span class='linenumber'>427</span>   </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"flashObj"</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>428</span>  
<span class='linenumber'>429</span>   </span><span class="COMM">/**
<span class='linenumber'>430</span>    * Gets the swf object.
<span class='linenumber'>431</span>    * @param {string?} opt_name The object/embed tag's id or name
<span class='linenumber'>432</span>    * @return {HTMLElement} the swf object.
<span class='linenumber'>433</span>    * @private
<span class='linenumber'>434</span>    */</span><span class="WHIT">
<span class='linenumber'>435</span>   </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">thisMovie</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>436</span>     </span><span class="NAME">opt_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_name</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">DEFAULT_FLASH_ID</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>437</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">navigator.appName.indexOf</span><span class="PUNC">(</span><span class="STRN">'Microsoft'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>438</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">[</span><span class="NAME">opt_name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>439</span>     </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>440</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>441</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>442</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>443</span>   
<span class='linenumber'>444</span> 
<span class='linenumber'>445</span>   </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>446</span>     
<span class='linenumber'>447</span>     </span><span class="COMM">//======================== Flash Embeded Object Functions ======================================</span><span class="WHIT">
<span class='linenumber'>448</span>     </span><span class="COMM">/**
<span class='linenumber'>449</span>      * Indicates if the opensocial library is loaded and initialize the flash element. 
<span class='linenumber'>450</span>      * &lt;p>
<span class='linenumber'>451</span>      * The objectId of the swf is defined in gagdet spec. If the swf is embeded by calling 
<span class='linenumber'>452</span>      * &lt;code>opensocial.flash.embedFlash&lt;/code> function, the detault objectId will be 'flashObj'.
<span class='linenumber'>453</span>      * &lt;/p>&lt;p>
<span class='linenumber'>454</span>      * This function is called by the swf's &lt;code>ExternalInterface&lt;/code> continuingly until it 
<span class='linenumber'>455</span>      * returns true.
<span class='linenumber'>456</span>      * &lt;/p>
<span class='linenumber'>457</span>      * 
<span class='linenumber'>458</span>      * @param {string?} objectId The object Id passed from the swf.
<span class='linenumber'>459</span>      * @return {boolean} true if all javascripts are loaded.
<span class='linenumber'>460</span>      * 
<span class='linenumber'>461</span>      * @member opensocial.flash
<span class='linenumber'>462</span>      */</span><span class="WHIT">
<span class='linenumber'>463</span>     </span><span class="NAME">jsReady</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">objectId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>464</span>       </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>465</span>         </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">swfObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>466</span>           </span><span class="NAME">swfObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">thisMovie</span><span class="PUNC">(</span><span class="NAME">objectId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>467</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>468</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">!</span><span class="NAME">swfObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>469</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>470</span>         </span><span class="NAME">INFO</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>471</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>472</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>473</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>474</span>     
<span class='linenumber'>475</span>     </span><span class="COMM">/**
<span class='linenumber'>476</span>      * Because &lt;code>gadgets.flash.embedFlash&lt;/code> cannot auto activate it in IE6, so here we 
<span class='linenumber'>477</span>      * need a special one.
<span class='linenumber'>478</span>      * &lt;p>
<span class='linenumber'>479</span>      * NOTE: to be deprecated.
<span class='linenumber'>480</span>      * &lt;/p>
<span class='linenumber'>481</span>      * 
<span class='linenumber'>482</span>      * @requires gadgets.flash
<span class='linenumber'>483</span>      * 
<span class='linenumber'>484</span>      * @param {string} swfUrl  The swf file's location.
<span class='linenumber'>485</span>      * @param {string} swfContainer  The HTML element id.
<span class='linenumber'>486</span>      * @param {string?} opt_playerVersion Required flash player version.
<span class='linenumber'>487</span>      * @param {Object.&lt;string, string>?} opt_params Flash object's parameters.
<span class='linenumber'>488</span>      * @param {string?} opt_upgradeMsgHTML The message if the flashplayer version is too old.
<span class='linenumber'>489</span>      * @return {boolean} True if the flash object is successfully embeded.
<span class='linenumber'>490</span>      * 
<span class='linenumber'>491</span>      * @member opensocial.flash
<span class='linenumber'>492</span>      */</span><span class="WHIT">
<span class='linenumber'>493</span>     </span><span class="NAME">embedFlash</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">swfUrl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">swfContainer</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_playerVersion</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_upgradeMsgHTML</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>494</span>       
<span class='linenumber'>495</span>       </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>496</span>       
<span class='linenumber'>497</span>       </span><span class="COMM">// Check container element</span><span class="WHIT">
<span class='linenumber'>498</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">container</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">swfContainer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>499</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">container</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>500</span>     
<span class='linenumber'>501</span>       </span><span class="COMM">// Check version</span><span class="WHIT">
<span class='linenumber'>502</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_playerVersion.match</span><span class="PUNC">(</span><span class="REGX">/(\d+)(?=[\.,]?)/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>503</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expectMajorVer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">version</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>504</span> 
<span class='linenumber'>505</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">      
<span class='linenumber'>506</span>         </span><span class="NAME">EXPORT</span><span class="PUNC">(</span><span class="STRN">"currentVer"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">gadgets.flash.getMajorVersion</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>507</span>         </span><span class="NAME">EXPORT</span><span class="PUNC">(</span><span class="STRN">"expectVer"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">expectMajorVer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>508</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>509</span>       
<span class='linenumber'>510</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets.flash.getMajorVersion</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">expectMajorVer</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>511</span>         </span><span class="NAME">opt_upgradeMsgHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_upgradeMsgHTML</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='linenumber'>512</span>             </span><span class="STRN">'&lt;span style="font-size:small;color:#777;"> '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='linenumber'>513</span>             </span><span class="STRN">'Please install or upgrade to '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='linenumber'>514</span>             </span><span class="STRN">'&lt;a href="http://www.adobe.com/cn/products/flashplayer/" '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='linenumber'>515</span>             </span><span class="STRN">'style="color:#36C;" target="_blank">Flash Player 9.0&lt;/a>.&lt;/span>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>516</span>         </span><span class="NAME">container.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_upgradeMsgHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>517</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>518</span>       </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>519</span>       
<span class='linenumber'>520</span>       </span><span class="COMM">/*
<span class='linenumber'>521</span>       opt_params['id'] = DEFAULT_FLASH_ID;
<span class='linenumber'>522</span>       opt_params['name'] = DEFAULT_FLASH_ID;
<span class='linenumber'>523</span>       return gadgets.flash.embedFlash(swfUrl, container, version, opt_params);
<span class='linenumber'>524</span>       */</span><span class="WHIT">
<span class='linenumber'>525</span>       </span><span class="COMM">// Generate the flash object element</span><span class="WHIT">
<span class='linenumber'>526</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>527</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">navigator.plugins</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">navigator.mimeTypes</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">navigator.mimeTypes.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>528</span>         </span><span class="COMM">// netscape plugin architecture</span><span class="WHIT">
<span class='linenumber'>529</span>         </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;embed src="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">swfUrl</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='linenumber'>530</span>                </span><span class="STRN">'" id="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='linenumber'>531</span>                </span><span class="STRN">'" name="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='linenumber'>532</span>                </span><span class="STRN">'" type="application/x-shockwave-flash"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>533</span>         </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> 
<span class='linenumber'>534</span>           </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" '</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>535</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>536</span>         </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'/>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>537</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>538</span>         </span><span class="COMM">// PC IE</span><span class="WHIT">
<span class='linenumber'>539</span>         </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;object id="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='linenumber'>540</span>                </span><span class="STRN">'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>541</span>         </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;param name="movie" value="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">swfUrl</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" />'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>542</span>         </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>543</span>           </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'width'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'height'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>544</span>             </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>545</span>           </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>546</span>             </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;param name="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" value="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" />'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>547</span>           </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>548</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>549</span>         </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"&lt;/object>"</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>550</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>551</span>       </span><span class="NAME">container.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">html</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>552</span>       
<span class='linenumber'>553</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>554</span> 
<span class='linenumber'>555</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>556</span>   
<span class='linenumber'>557</span>     </span><span class="COMM">/**
<span class='linenumber'>558</span>      * Get the swf object.
<span class='linenumber'>559</span>      * @param {string?} opt_name The object/embed tag's id or name
<span class='linenumber'>560</span>      * @return {HTMLElement} the swf object.
<span class='linenumber'>561</span>      * @member opensocial.flash
<span class='linenumber'>562</span>      */</span><span class="WHIT">
<span class='linenumber'>563</span>     </span><span class="NAME">getFlash</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>564</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">thisMovie</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>565</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>566</span>     
<span class='linenumber'>567</span>     </span><span class="COMM">//======================== Environment Wrapped Accessors ===========================</span><span class="WHIT">
<span class='linenumber'>568</span>     
<span class='linenumber'>569</span>     </span><span class="COMM">/**
<span class='linenumber'>570</span>      * Returns the domain from the referer.
<span class='linenumber'>571</span>      * @return {string} The domain.
<span class='linenumber'>572</span>      * @member opensocial.flash
<span class='linenumber'>573</span>      */</span><span class="WHIT">
<span class='linenumber'>574</span>     </span><span class="NAME">getContainerDomain</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>575</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pattern</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/(\w+):\/\/([\w.]+)\/(\S*)/</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>576</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.referrer.match</span><span class="PUNC">(</span><span class="NAME">pattern</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>577</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>578</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>579</span> 
<span class='linenumber'>580</span>     </span><span class="COMM">/**
<span class='linenumber'>581</span>      * Returns the name of the in gadgets.views static class.
<span class='linenumber'>582</span>      * @requires gadgets.views
<span class='linenumber'>583</span>      * @return {gadgets.views.ViewType | string} The view name.
<span class='linenumber'>584</span>      * @member opensocial.flash
<span class='linenumber'>585</span>      */</span><span class="WHIT">
<span class='linenumber'>586</span>     </span><span class="NAME">getCurrentView</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>587</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.views</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>588</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">gadgets.views.getCurrentView</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>589</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>590</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>591</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>592</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>593</span>     
<span class='linenumber'>594</span>     </span><span class="COMM">/**
<span class='linenumber'>595</span>      * Returns the parameters passed into this gadget for this view.
<span class='linenumber'>596</span>      * @requires gadgets.views
<span class='linenumber'>597</span>      * @return {Object.&lt;string, string>} The param object.
<span class='linenumber'>598</span>      * @member opensocial.flash
<span class='linenumber'>599</span>      */</span><span class="WHIT">
<span class='linenumber'>600</span>     </span><span class="NAME">getViewParams</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>601</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.views</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>602</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">gadgets.views.getParams</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>603</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>604</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>605</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>606</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>607</span>     
<span class='linenumber'>608</span>     </span><span class="COMM">/**
<span class='linenumber'>609</span>      * Indicates if the app is only one gadget on the page or not.
<span class='linenumber'>610</span>      * @requires gadget.views
<span class='linenumber'>611</span>      * @return {Boolean} True if it's the only one gadget.
<span class='linenumber'>612</span>      * @member opensocial.flash
<span class='linenumber'>613</span>      */</span><span class="WHIT">
<span class='linenumber'>614</span>     </span><span class="NAME">isOnlyVisible</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>615</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.views</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>616</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">gadgets.views.getCurrentView</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">isOnlyVisibleGadget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>617</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>618</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>619</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>620</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>621</span> 
<span class='linenumber'>622</span>     </span><span class="COMM">/**
<span class='linenumber'>623</span>      * Sets the width for the flash stage. It is very usefull for dynamic loading and view 
<span class='linenumber'>624</span>      * switching.
<span class='linenumber'>625</span>      * @param {number} newWidth New width (in pixel) to be applied.
<span class='linenumber'>626</span>      * @member opensocial.flash
<span class='linenumber'>627</span>      */</span><span class="WHIT">
<span class='linenumber'>628</span>     </span><span class="NAME">setStageWidth</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">newWidth</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>629</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">swfObj.width</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">newWidth</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>630</span>         </span><span class="NAME">swfObj.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newWidth</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>631</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>632</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>633</span>     
<span class='linenumber'>634</span>     
<span class='linenumber'>635</span>     </span><span class="COMM">/**
<span class='linenumber'>636</span>      * Sets the height for the flash stage. It is very usefull for dynamic loading and view 
<span class='linenumber'>637</span>      * switching.
<span class='linenumber'>638</span>      * @requires gadgets.window
<span class='linenumber'>639</span>      * @param {number} newHeight New height (in pixel) to be applied.
<span class='linenumber'>640</span>      * @member opensocial.flash
<span class='linenumber'>641</span>      */</span><span class="WHIT">
<span class='linenumber'>642</span>     </span><span class="NAME">setStageHeight</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">newHeight</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>643</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">swfObj.height</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">newHeight</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>644</span>         </span><span class="NAME">swfObj.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newHeight</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>645</span>         </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.window</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.window.adjustHeight</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>646</span>           </span><span class="NAME">gadgets.window.adjustHeight</span><span class="PUNC">(</span><span class="NAME">newHeight</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>647</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>648</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>649</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>650</span>     
<span class='linenumber'>651</span>     
<span class='linenumber'>652</span>     </span><span class="COMM">//======================== Opensocial Data RPCs ===========================</span><span class="WHIT">
<span class='linenumber'>653</span>     </span><span class="COMM">/**
<span class='linenumber'>654</span>      * Sends out the request for a person.
<span class='linenumber'>655</span>      * 
<span class='linenumber'>656</span>      * @param {string} reqID The request id.
<span class='linenumber'>657</span>      * @param {opensocial.IdSpec.PersonId | string} id OWNER or VIEWER.
<span class='linenumber'>658</span>      * @param {Object.&lt;opensocial.DataRequest.PeopleRequestField, Object>} opt_params 
<span class='linenumber'>659</span>      *            A map of &lt;code>opensocial.DataRequest.PeopleRequestField&lt;/code> names and values.
<span class='linenumber'>660</span>      * @member opensocial.flash
<span class='linenumber'>661</span>      */</span><span class="WHIT">
<span class='linenumber'>662</span>     </span><span class="NAME">fetchPerson</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>663</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>664</span>       </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchPersonRequest</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>665</span>       </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>666</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>667</span>           </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">person</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>668</span>           </span><span class="NAME">swfObj.handleFetchPerson</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">person</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>669</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>670</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>671</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>672</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>673</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>674</span> 
<span class='linenumber'>675</span>     </span><span class="COMM">/**
<span class='linenumber'>676</span>      * Sends out the request for friends of a person.
<span class='linenumber'>677</span>      * 
<span class='linenumber'>678</span>      * @param {string} reqID The request id.
<span class='linenumber'>679</span>      * @param {Object} idSpec A wrapped &lt;code>opensocial.IdSpec&lt;/code> object.
<span class='linenumber'>680</span>      * @param {Object.&lt;opensocial.DataRequest.PeopleRequestField, Object>} opt_params 
<span class='linenumber'>681</span>      *            A map of &lt;code>opensocial.DataRequest.PeopleRequestField&lt;/code> names and values.
<span class='linenumber'>682</span>      * @member opensocial.flash
<span class='linenumber'>683</span>      */</span><span class="WHIT">
<span class='linenumber'>684</span>     </span><span class="NAME">fetchPeople</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>685</span>       </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>686</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>687</span>       </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchPeopleRequest</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>688</span>       </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>689</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>690</span>           </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">people</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>691</span>           </span><span class="NAME">swfObj.handleFetchPeople</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">people</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>692</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>693</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>694</span>         </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='linenumber'>695</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>696</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>697</span>     
<span class='linenumber'>698</span>     </span><span class="COMM">/**
<span class='linenumber'>699</span>      * Sends out the request for personal app data. 
<span class='linenumber'>700</span>      * 
<span class='linenumber'>701</span>      * @param {string} reqID The request id.
<span class='linenumber'>702</span>      * @param {Object} idSpec A wrapped &lt;code>opensocial.IdSpec&lt;/code> object.
<span class='linenumber'>703</span>      * @param {Array.&lt;string>} keys App keys, '*' for all.
<span class='linenumber'>704</span>      * @param {Object.&lt;opensocial.DataRequest.DataRequestField, Object>?} opt_params 
<span class='linenumber'>705</span>      *            A map of &lt;code>opensocial.DataRequest.DataRequestField&lt;/code> names and values.
<span class='linenumber'>706</span>      * @member opensocial.flash
<span class='linenumber'>707</span>      */</span><span class="WHIT">
<span class='linenumber'>708</span>     </span><span class="NAME">fetchPersonAppData</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>709</span>       </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>710</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>711</span>       </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchPersonAppDataRequest</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'d'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>712</span>       </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>713</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>714</span>           </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dataSet</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'d'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='linenumber'>715</span>           </span><span class="COMM">//dataSet is a Object.&lt;opensocial.IdSpec.PersonId, Object.&lt;string, Object>> object.</span><span class="WHIT">
<span class='linenumber'>716</span>           </span><span class="NAME">swfObj.handleFetchPersonAppData</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dataSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>717</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>718</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>719</span>         </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='linenumber'>720</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>721</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>722</span>     
<span class='linenumber'>723</span>     
<span class='linenumber'>724</span>     </span><span class="COMM">/**
<span class='linenumber'>725</span>      * Sends out the update request for personal app data.
<span class='linenumber'>726</span>      * 
<span class='linenumber'>727</span>      * @param {string} reqID The request id.
<span class='linenumber'>728</span>      * @param {opensocial.IdSpec.PersonId | string} id only VIEWER is valid
<span class='linenumber'>729</span>      * @param {string} key A data key.
<span class='linenumber'>730</span>      * @param {Object} value New value.
<span class='linenumber'>731</span>      * @member opensocial.flash
<span class='linenumber'>732</span>      */</span><span class="WHIT">
<span class='linenumber'>733</span>     </span><span class="NAME">updatePersonAppData</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>734</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>735</span>       </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newUpdatePersonAppDataRequest</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'u'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>736</span>       </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>737</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>738</span>           </span><span class="NAME">getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'u'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>739</span>           </span><span class="NAME">swfObj.handleUpdatePersonAppData</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>740</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>741</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>742</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>743</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>744</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>745</span>     
<span class='linenumber'>746</span>     
<span class='linenumber'>747</span>     </span><span class="COMM">/**
<span class='linenumber'>748</span>      * Sends out the remove request for personal app data.
<span class='linenumber'>749</span>      * 
<span class='linenumber'>750</span>      * @param {string} reqID The request id.
<span class='linenumber'>751</span>      * @param {opensocial.IdSpec.PersonId | string} id only VIEWER is valid
<span class='linenumber'>752</span>      * @param {Array.&lt;string>} keys App keys, '*' for all.
<span class='linenumber'>753</span>      * @member opensocial.flash
<span class='linenumber'>754</span>      */</span><span class="WHIT">
<span class='linenumber'>755</span>     </span><span class="NAME">removePersonAppData</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>756</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>757</span>       </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newRemovePersonAppDataRequest</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'r'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>758</span>       </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>759</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>760</span>           </span><span class="NAME">getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'r'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>761</span>           </span><span class="NAME">swfObj.handleRemovePersonAppData</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>762</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>763</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>764</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>765</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>766</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>767</span> 
<span class='linenumber'>768</span>     </span><span class="COMM">/**
<span class='linenumber'>769</span>      * Sends out the request for personal activities.
<span class='linenumber'>770</span>      * 
<span class='linenumber'>771</span>      * @param {string} reqID The request id.
<span class='linenumber'>772</span>      * @param {Object} idSpec A wrapped &lt;code>opensocial.IdSpec&lt;/code> object.
<span class='linenumber'>773</span>      * @param {Object.&lt;opensocial.DataRequest.ActivityRequestField, Object>?} opt_params 
<span class='linenumber'>774</span>      *            A map of &lt;code>opensocial.DataRequest.ActivityRequestField&lt;/code> names and
<span class='linenumber'>775</span>      *            values.
<span class='linenumber'>776</span>      * @member opensocial.flash
<span class='linenumber'>777</span>      */</span><span class="WHIT">
<span class='linenumber'>778</span>     </span><span class="NAME">fetchActivities</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>779</span>       </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>780</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>781</span>       </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchActivitiesRequest</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>782</span>       </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>783</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>784</span>           </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">activities</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapObject</span><span class="PUNC">(</span><span class="NAME">getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>785</span>           </span><span class="NAME">swfObj.handleFetchActivities</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">activities</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>786</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>787</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>788</span>         </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='linenumber'>789</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>790</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>791</span> 
<span class='linenumber'>792</span>     </span><span class="COMM">/**
<span class='linenumber'>793</span>      * Sends out the request to creat an activity.
<span class='linenumber'>794</span>      * 
<span class='linenumber'>795</span>      * @param {string} reqID The request id.
<span class='linenumber'>796</span>      * @param {Object} activity A wrapped &lt;code>opensocial.Activity&lt;/code> object.
<span class='linenumber'>797</span>      * @param {opensocial.CreateActivityPriority | string} priority 
<span class='linenumber'>798</span>      *            An &lt;code>opensocial.CreateActivityPriority&lt;/code> value.
<span class='linenumber'>799</span>      * @member opensocial.flash
<span class='linenumber'>800</span>      */</span><span class="WHIT">
<span class='linenumber'>801</span>     </span><span class="NAME">requestCreateActivity</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">activity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>802</span>       </span><span class="NAME">activity</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">activity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Activity</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>803</span>       </span><span class="NAME">opensocial.requestCreateActivity</span><span class="PUNC">(</span><span class="NAME">activity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>804</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>805</span>           </span><span class="NAME">getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>806</span>           </span><span class="NAME">swfObj.handleRequestCreateActivity</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>807</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>808</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>809</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>810</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>811</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>812</span> 
<span class='linenumber'>813</span>     </span><span class="COMM">/**
<span class='linenumber'>814</span>      * Sends out the request to send a message.
<span class='linenumber'>815</span>      * &lt;p>TODO: &lt;code>opensocial.NavigationParameters opt_params&lt;/code> is not implemented.&lt;/p>
<span class='linenumber'>816</span>      * 
<span class='linenumber'>817</span>      * @param {string} reqID The request id.
<span class='linenumber'>818</span>      * @param {Array.&lt;string>} recipients An ID, array of IDs, or a group reference, like
<span class='linenumber'>819</span>      *            VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS.
<span class='linenumber'>820</span>      * @param {Object} message A wrapped &lt;code>opensocial.Message&lt;/code> object.
<span class='linenumber'>821</span>      * @member opensocial.flash
<span class='linenumber'>822</span>      */</span><span class="WHIT">
<span class='linenumber'>823</span>     </span><span class="NAME">requestSendMessage</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">recipients</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>824</span>       </span><span class="NAME">message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>825</span>       </span><span class="NAME">opensocial.requestSendMessage</span><span class="PUNC">(</span><span class="NAME">recipients</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>826</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>827</span>           </span><span class="NAME">getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>828</span>           </span><span class="NAME">swfObj.handleRequestSendMessage</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>829</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>830</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>831</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>832</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>833</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>834</span> 
<span class='linenumber'>835</span>     </span><span class="COMM">/**
<span class='linenumber'>836</span>      * Sends out the request to share the app.
<span class='linenumber'>837</span>      * &lt;p>TODO: &lt;code>opensocial.NavigationParameters opt_params&lt;/code> is not implemented.&lt;/p>
<span class='linenumber'>838</span>      * 
<span class='linenumber'>839</span>      * @param {string} reqID The request id.
<span class='linenumber'>840</span>      * @param {Array.&lt;string>} recipients An ID, array of IDs, or a group reference, like
<span class='linenumber'>841</span>      *            VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS.
<span class='linenumber'>842</span>      * @param {Object} reason A wrapped &lt;code>opensocial.Message&lt;/code> object.
<span class='linenumber'>843</span>      * @member opensocial.flash
<span class='linenumber'>844</span>      */</span><span class="WHIT">
<span class='linenumber'>845</span>     </span><span class="NAME">requestShareApp</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">recipients</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>846</span>       </span><span class="NAME">reason</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unwrapObject</span><span class="PUNC">(</span><span class="NAME">reason</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>847</span>       </span><span class="NAME">opensocial.requestShareApp</span><span class="PUNC">(</span><span class="NAME">recipients</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>848</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>849</span>           </span><span class="NAME">getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>850</span>           </span><span class="NAME">swfObj.handleRequestShareApp</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>851</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>852</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>853</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>854</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>855</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>856</span>     
<span class='linenumber'>857</span>     </span><span class="COMM">/**
<span class='linenumber'>858</span>      * Sends out the request permissions.
<span class='linenumber'>859</span>      * 
<span class='linenumber'>860</span>      * @param {string} reqID The request id.
<span class='linenumber'>861</span>      * @param {Array.&lt;opensocial.Permission | string>} permissions An array of 
<span class='linenumber'>862</span>      *            &lt;code>opensocial.Permission&lt;/code> values.
<span class='linenumber'>863</span>      * @param {string} reason Text of the reason to request the permissions.
<span class='linenumber'>864</span>      * @member opensocial.flash
<span class='linenumber'>865</span>      */</span><span class="WHIT">
<span class='linenumber'>866</span>     </span><span class="NAME">requestPermission</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">permissions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>867</span>       </span><span class="NAME">opensocial.requestPermission</span><span class="PUNC">(</span><span class="NAME">permissions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>868</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>869</span>           </span><span class="NAME">getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>870</span>           </span><span class="NAME">swfObj.handleRequestPermission</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>871</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>872</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>873</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>874</span>       </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>875</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>876</span> 
<span class='linenumber'>877</span>     </span><span class="COMM">/**
<span class='linenumber'>878</span>      * Sends request to a remote site to get or post data.
<span class='linenumber'>879</span>      * 
<span class='linenumber'>880</span>      * @param {string} reqID The request id.
<span class='linenumber'>881</span>      * @param {string} url The remote site
<span class='linenumber'>882</span>      * @param {Object.&lt;gadgets.io.RequestParameters, Object>?} opt_params 
<span class='linenumber'>883</span>      *            Parameters for the request
<span class='linenumber'>884</span>      * @member opensocial.flash
<span class='linenumber'>885</span>      */</span><span class="WHIT">
<span class='linenumber'>886</span>     </span><span class="NAME">makeRequest</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>887</span>       </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>888</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">postData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">gadgets.io.RequestParameters.POST_DATA</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>889</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">postData</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>890</span>         </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">gadgets.io.RequestParameters.POST_DATA</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">gadgets.io.encodeValues</span><span class="PUNC">(</span><span class="NAME">postData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>891</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>892</span>       </span><span class="NAME">gadgets.io.makeRequest</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>893</span>         </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>894</span>           </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">[</span><span class="STRN">'error'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="STRN">'rc'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">200</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>895</span>             </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">[</span><span class="STRN">'text'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>896</span>             </span><span class="NAME">err</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'OpensocialError'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>897</span>             </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">err</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>898</span>           </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>899</span>           </span><span class="NAME">swfObj.handleMakeRequest</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj.data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>900</span>         </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>901</span>           </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>902</span>         </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>903</span>       </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>904</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>905</span> 
<span class='linenumber'>906</span>     </span><span class="COMM">/**
<span class='linenumber'>907</span>      * Sends the rpc register request to container to register a service on this app.
<span class='linenumber'>908</span>      * 
<span class='linenumber'>909</span>      * @param {string} The service to be register.
<span class='linenumber'>910</span>      * @param {string} The handler function name on the flash object.
<span class='linenumber'>911</span>      * @member opensocial.flash
<span class='linenumber'>912</span>      */</span><span class="WHIT">
<span class='linenumber'>913</span>     </span><span class="NAME">rpcRegister</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handlerName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>914</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>915</span>         </span><span class="NAME">gadgets.rpc.registerDefault</span><span class="PUNC">(</span><span class="NAME">swfObj</span><span class="PUNC">[</span><span class="NAME">handlerName</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>916</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>917</span>         </span><span class="NAME">gadgets.rpc.register</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>918</span>           </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>919</span>             </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>920</span>             </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>921</span>               </span><span class="NAME">args.push</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>922</span>             </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>923</span>             </span><span class="NAME">swfObj</span><span class="PUNC">[</span><span class="NAME">handlerName</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">apply</span><span class="PUNC">(</span><span class="NAME">swfObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>924</span>           </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>925</span>             </span><span class="NAME">handleError</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>926</span>           </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>927</span>         </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>928</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>929</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>930</span> 
<span class='linenumber'>931</span>     </span><span class="COMM">/**
<span class='linenumber'>932</span>      * Sends the rpc unregister request to container.
<span class='linenumber'>933</span>      * 
<span class='linenumber'>934</span>      * @param {string} The service to be unregister.
<span class='linenumber'>935</span>      * @member opensocial.flash
<span class='linenumber'>936</span>      */</span><span class="WHIT">
<span class='linenumber'>937</span>     </span><span class="NAME">rpcUnregister</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>938</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>939</span>         </span><span class="NAME">gadgets.rpc.unregisterDefault</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>940</span>       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>941</span>         </span><span class="NAME">gadgets.rpc.unregister</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>942</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>943</span>     </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='linenumber'>944</span> 
<span class='linenumber'>945</span>     </span><span class="COMM">/**
<span class='linenumber'>946</span>      * Sends the rpc call request to a service on another app or container on the page.
<span class='linenumber'>947</span>      * 
<span class='linenumber'>948</span>      * @param {string} reqID The request id.
<span class='linenumber'>949</span>      * @param {string?} targetId The target app id, null to call the parent.
<span class='linenumber'>950</span>      * @param {string} serviceName The service name registered on the target.
<span class='linenumber'>951</span>      * @param {Array.&lt;Object>?} argsArray The array of args to be passed to the service.
<span class='linenumber'>952</span>      * @member opensocial.flash
<span class='linenumber'>953</span>      */</span><span class="WHIT">
<span class='linenumber'>954</span>     </span><span class="NAME">rpcCall</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">targetId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">argsArray</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>955</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">reqArgs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">targetId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>956</span>         </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArgs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">reqID</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>957</span>         </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>958</span>           </span><span class="NAME">resArgs.push</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>959</span>         </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>960</span>         </span><span class="NAME">swfObj.handleRpcCall.apply</span><span class="PUNC">(</span><span class="NAME">swfObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">resArgs</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>961</span>       </span><span class="PUNC">}</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>962</span>       
<span class='linenumber'>963</span>       </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">argsArray</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>964</span>         </span><span class="NAME">forEach</span><span class="PUNC">(</span><span class="NAME">argsArray</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'>965</span>           </span><span class="NAME">reqArgs.push</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>966</span>         </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>967</span>       </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>968</span>       </span><span class="NAME">gadgets.rpc.call.apply</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reqArgs</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>969</span>     </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'>970</span> 
<span class='linenumber'>971</span> 
<span class='linenumber'>972</span>   </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>973</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>974</span> 
<span class='linenumber'>975</span> </span></pre></body></html>